/**
 * @author yusak
 */

ChaShaKu.OptionMenu = Ext.extend(Ext.app.Module,{
	id: "optionMenu",
	init: function(){
		this.reading = new Ext.menu.CheckItem({id: 'reading',text: 'Reading',checkHandler: this.checkChange});
		this.pronunciation = new Ext.menu.CheckItem({id: 'pronunciation',text: 'Pronunciation',checkHandler: this.checkChange});
		this.partOfSpeech = new Ext.menu.CheckItem({id: 'part_of_speech',text: 'Part of Speech',checkHandler: this.checkChange});
		this.ctype = new Ext.menu.CheckItem({id: 'ctype',text: 'Ctype',checkHandler: this.checkChange});
		this.cform = new Ext.menu.CheckItem({id: 'cform',text: 'Cform',checkHandler: this.checkChange});
		this.option = new Ext.Toolbar.Button({
			iconCls: 'option',
			text: 'Tag Option',
			tooltip: {text:'グリッドに表示するタグを選択してください', title:'表示タグ', autoHide:true},
			menu: {items:[
				this.reading,
				this.pronunciation,
				this.partOfSpeech,
				this.ctype,
				this.cform
			]}
		});
	},
	run: function(){
		this.app.viewport.toolbar.add('-',this.option);
	},
	checkChange: function(checkItem,checked){
		var id = checkItem.getId();
		Ext.app.Grid.tagConditons[id] = checked;
		var el = Ext.select('.' + id);
		el.enableDisplayMode();
		if(checked){
			el.show();
		}else {
			el.hide();
		}
	}
});